<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title>JSDoc: Source: AABB.js</title>

    <script src="scripts/prettify/prettify.js"> </script>
    <script src="scripts/prettify/lang-css.js"> </script>
    <!--[if lt IE 9]>
      <script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
    <![endif]-->
    <link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
    <link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
</head>

<body>

<div id="main">

    <h1 class="page-title">Source: AABB.js</h1>

    



    
    <section>
        <article>
            <pre class="prettyprint source linenums"><code>/**
 * AABB.
 * Don't instantiate this class in your code.
 * @class
 * @private
 */
function AABB() {

    /**
     * @type {number}
     */
    this.minX = + Infinity;
    /**
     * @type {number}
     */
    this.minY = + Infinity;

    /**
     * @type {number}
     */
    this.maxX = - Infinity;
    /**
     * @type {number}
     */
    this.maxY = - Infinity;

}

Object.defineProperties(AABB.prototype, {

    /**
     * width
     * @memberof AABB#
     * @readonly
     * @type {number}
     */
    width: {

        get: function() {
            return this.maxX - this.minX;
        }

    },

    /**
     * height
     * @memberof AABB#
     * @readonly
     * @type {number}
     */
    height: {

        get: function() {
            return this.maxY - this.minY;
        }

    }

});

Object.assign(AABB.prototype, {

    reset: function() {

        this.minX = + Infinity;
        this.minY = + Infinity;

        this.maxX = - Infinity;
        this.maxY = - Infinity;

    },

    expand: function(point) {
    
        this.minX = Math.min(point.x, this.minX);
        this.minY = Math.min(point.y, this.minY);
        this.maxX = Math.max(point.x, this.maxX);
        this.maxY = Math.max(point.y, this.maxY);

    },

    expands: function(points) {

        for (var i = 0, l = points.length; i &lt; l; i++) {
            this.expand(points[i]);
        }

    },

    intersects: function(aabb) {
        return aabb.maxX &lt; this.minX || aabb.minX > this.maxX ||
        aabb.maxY &lt; this.minY || aabb.minY > this.maxY ? false : true;
    },

    containsPoint: function(point) {
        return point.x &lt;= this.maxX &amp;&amp; point.x >= this.minX &amp;&amp;
        point.y &lt;= this.maxY &amp;&amp; point.y >= this.minY ? true : false;
    },

    containsPoints: function(points) {
        for (var i = 0, l = points.length; i &lt; l; i++) {
            if (!this.containsPoint(points[i])) {
                return false;
            }
        }
        return true;
    },

    size: function() {
        return {
            width: this.maxX - this.minX,
            height: this.maxY - this.minY
        };
    }

});

export {AABB};</code></pre>
        </article>
    </section>




</div>

<nav>
    <h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="DCEL.html">DCEL</a></li></ul>
</nav>

<br class="clear">

<footer>
    Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Mon Aug 27 2018 23:15:07 GMT+0800 (CST)
</footer>

<script> prettyPrint(); </script>
<script src="scripts/linenumber.js"> </script>
</body>
</html>
